package com.ruoyi.system.controller.logistics;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.NoticeSum;
import com.ruoyi.system.service.INoticeSumService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 通告汇总Controller
 * 
 * @author ruoyi
 * @date 2023-12-26
 */
@RestController
@RequestMapping("/noticeSum")
public class NoticeSumController extends BaseController
{
    @Autowired
    private INoticeSumService noticeSumService;

    /**
     * 查询通告汇总列表
     */
    @RequiresPermissions("system:noticeSum:list")
    @GetMapping("/list")
    public TableDataInfo list(NoticeSum noticeSum)
    {
        startPage();
        List<NoticeSum> list = noticeSumService.selectNoticeSumList(noticeSum);
        return getDataTable(list);
    }

    /**
     * 导出通告汇总列表
     */
    @RequiresPermissions("system:noticeSum:export")
    @Log(title = "通告汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NoticeSum noticeSum)
    {
        List<NoticeSum> list = noticeSumService.selectNoticeSumList(noticeSum);
        ExcelUtil<NoticeSum> util = new ExcelUtil<NoticeSum>(NoticeSum.class);
        util.exportExcel(response, list, "通告汇总数据");
    }

    /**
     * 获取通告汇总详细信息
     */
    @RequiresPermissions("system:noticeSum:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(noticeSumService.selectNoticeSumById(id));
    }

    /**
     * 新增通告汇总
     */
    @RequiresPermissions("system:noticeSum:add")
    @Log(title = "通告汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NoticeSum noticeSum)
    {
        return toAjax(noticeSumService.insertNoticeSum(noticeSum));
    }

    /**
     * 修改通告汇总
     */
    @RequiresPermissions("system:noticeSum:edit")
    @Log(title = "通告汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NoticeSum noticeSum)
    {
        return toAjax(noticeSumService.updateNoticeSum(noticeSum));
    }

    /**
     * 删除通告汇总
     */
    @RequiresPermissions("system:noticeSum:remove")
    @Log(title = "通告汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(noticeSumService.deleteNoticeSumByIds(ids));
    }
}
